import React from 'react'

export default class NameForm extends React.Component {
  constructor(props) {
    super(props)
    this.handleSubmit = this.handleSubmit.bind(this);
    this.input = React.createRef();
  }

  handleSubmit(event) {
    alert('A name was submitted ' + this.input.current.value);
    event.preventDefault()
  }
  // 非受控组件
  render() {
    return (
      <form onSubmit={this.handleSubmit}>
        <label htmlFor="">
          Name: <input type="text" ref={this.input} defalutValue="abc" />
        </label>
        <input type="submit" value="Submit"/>
      </form>
    )
  }
}

